<template>
  <div class="app-container">
    <el-scrollbar class="form-scrollbar">
      <div class="divClass"></div>
      <el-row type="flex" class="row" justify="center">
        <el-col :span="2"></el-col>
        <el-col :span="3">
          <el-select
            @change="selectChange"
            v-model="paramName"
            placeholder="请选择"
          >
            <el-option
              v-for="item in params"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-col>
        <el-col :span="9">
          <el-input v-model="input" :placeholder="tip"></el-input>
        </el-col>
        <el-col :span="4">
          <el-button type="success" @click="searchClick">查询</el-button>
        </el-col>
        <el-col :span="6"></el-col>
      </el-row>
    </el-scrollbar>
  </div>
</template>
<script>
export default {
  data() {
    return {
      tip: '',
      params: [
        {
          value: 'CommodityId',
          label: '商品/HS编码'
        }
      ],
      paramName: '',
      input: ''
    }
  },
  methods: {
    selectChange(val) {
      switch (val) {
        case 'CommodityId':
          this.tip = '请输入商品编码或HS编码'
          break
        default:
          this.$message({
            type: 'warning',
            message: '请选择查询条件'
          })
          break
      }
    },
    searchClick() {
      console.log(this.paramName)
      console.log(this.input)
      if (this.paramName === '') {
        console.log(1)
        this.$message({
          message: '请选择查询条件',
          type: 'warning'
        })
        return false
      }
      if (this.input === '') {
        this.$message({
          message: '请输入查询内容',
          type: 'warning'
        })
        return false
      }
      const data = {
        name: this.paramName,
        value: this.input
      }
      this.$router.push({
        name: 'seachDetailCustomData',
        query: {
          targetData: data
        }
      })
    }
  }
}
</script>

<style scoped>
.app-container {
  padding-top: 20px;
  height: calc(100vh - 96px);
}
.form-scrollbar {
  height: calc(100vh - 116px);
  background: url("~@/assets/search-bg.jpg") no-repeat;
  background-size: cover;
}
.box-card {
  height: 80%;
  margin: 10px 100px 0px;
}

.row {
  margin: 22% 10% 80% 15%;
  z-index: 999;
  position: absolute;
  width: 95%;
}

.divClass {
  width: 70%;
  height: 100px;
  margin: 20% 10% 80% 15%;
  filter: alpha(opacity=50);
  opacity: 0.5;
  z-index: 99;
  position: absolute;
  background-color: gray;
  border-radius: 5px;
}
</style>
